$(function(){
//nav效果
	$("#nav li:eq(0)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#beauty").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
	}).mouseleave(function(){
		$("#beauty").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(1)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#milk").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#milk").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(2)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#tax").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#tax").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	$("#nav li:eq(3)").mouseenter(function(){
		$(this).children("span").stop(true).animate({"width":"80","left":"0"},500);
		$("#overseas").show().mouseover(function(){
			$(this).show();
		}).mouseout(function(){
			$(this).hide();
		});
	}).mouseleave(function(){
		$("#overseas").hide();
		$(this).children("span").animate({"width":"0","left":"40"},500);
	});
	
//nav 搜索框
   	$("#nav .text").focus(function(){
   		$(this).animate({"width":"168"},1000);
   	}).blur(function(){
   		$(this).animate({"width":"134"},1000);
   	});
   	
//floor2效果
	$(window).scroll(function(){
		var 
			scrollT=document.documentElement.scrollTop||document.body.scrollTop;
		if(scrollT>=500){
			$("#floor2").fadeIn();
		}else{
			$("#floor2").fadeOut();
		}
	});

	$(".a_8").click(function(){
		timer1=setInterval(function(){
			var 
				scrollT=document.documentElement.scrollTop||document.body.scrollTop,
				
				speed=Math.round((0-scrollT)/10);
			document.documentElement.scrollTop=document.body.scrollTop=scrollT+speed;
			
			if(speed==0){
				clearInterval(timer1);
			}
		},30);
	}); 
	
   	
});

window.onload=function(){
	
	var 
		oNav=document.getElementById("nav"),
		oFloor=document.getElementById("floor2"),
		aA=oFloor.getElementsByTagName("a"),
		onOff=true,
		timer1=null,
		arr_F=[],
		s=$(".side_scroll");
		for(var i=0;i<s.length;i++){
			arr_F.push(s[i].offsetTop);
		}
	for(var i=0;i<aA.length-1;i++){
		(function(i){
			aA[i].onclick=function(){
				if(onOff){
					onOff=false;
					timer1=setInterval(function(){
						var 
							scrollT=document.documentElement.scrollTop||document.body.scrollTop,
							s=i+1,
							speed=Math.round((arr_F[i]-90-scrollT)/10);
						document.documentElement.scrollTop=document.body.scrollTop=scrollT+speed;
						if(speed==0){
							clearInterval(timer1);
							onOff=true;
						}
					},30);
				}
			}
		})(i);
	}

//封装声明
function $1(obj){
	var firstChar=obj.charAt(0);
	if(firstChar=="#"){
		return document.getElementById(obj.substring(1));
	}else if(firstChar=="."){
		var aEls=document.getElementsByTagName("*");
		var arr=[];
		for(var i=0;i<aEls.length;i++){
			var arrclassName=aEls[i].className.split(" ");
			for(var j=0;j<arrclassName.length;j++){
				if(arrclassName[j]==obj.substring(1)){
					arr.push(aEls[i]);
					break;
				}
			}
		}
		return arr;
	}else{
		return document.getElementsByTagName(obj); 
	}
}	
};
